package com.wanglj.controller;

import com.wanglj.model.dto.TicketDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.io.Serializable;

/**
 * @author 955
 * @title
 * @date 2020/11/30 20:10
 */
@RestController
public class BuyController  {
    @Autowired
    private RestTemplate restTemplate;
    @GetMapping("/tickets")
    public String buy( String name,Integer num){
        TicketDTO ticketDTO=new TicketDTO();
        ticketDTO.setName(name);
        ticketDTO.setNum(num);

        //远程调用
        String result=
                restTemplate.postForEntity("http://127.0.0:8089/movies/"+name+"/"+num, ticketDTO,String.class).getBody();
    return result;
    }

}
